package monopoly;



import java.util.Scanner;


public class player {
        public static void pay_rent(){
                if (vars.player_position == 5 || vars.player_position == 15 || vars.player_position == 25 || vars.player_position == 35) {
                        
                        vars.var = railroadRent();
                        System.out.println("You land on "+ arrays.property_name[vars.player_position]+ " and are charged $" + vars.var + ".");
                        vars.player_money = vars.player_money - vars.var;
                        
                        
                } else if (vars.player_position == 12) {
                        if (arrays.property_type[28] == 2) {
                                System.out.println("You land on The Electric Company and are charged $"
                                                                + 10 * vars.dice + " rent");
                                vars.player_money = vars.player_money - 10 * vars.dice;
                        } else {
                                System.out.println("You land on The Electric Company and are charged $"+ 4 * vars.dice + " rent");
                                vars.player_money = vars.player_money - 4 * vars.dice;
                        }
                } else if (vars.player_position == 28) {
                        if (arrays.property_type[12] == 2) {
                                System.out.println("You land on The Water Works and are charged $"+ 10 * vars.dice + " rent");
                                vars.player_money = vars.player_money - 10* vars.dice;
                        } else {
                                System.out.println("You land on The Water Works and are charged $"+ 4 * vars.dice + " rent");
                                vars.player_money = vars.player_money - 4* vars.dice;
                        }

                } else {
                        System.out.println("You land on "+arrays.property_name[vars.player_position]+"; which is owned by the computer.");
                        System.out.println("You pay $"+arrays.property_rent[vars.player_position]+" rent.");
                        vars.player_money=vars.player_money-arrays.property_rent[vars.player_position];
                        vars.computer_money=vars.computer_money+arrays.property_rent[vars.player_position];
                }
        }
        
        @SuppressWarnings("resource")
        public static void buy_property(){
                Scanner keyboard;
                keyboard = new Scanner(System.in);
                System.out.println("You land on "+ arrays.property_name[vars.player_position] + ".");
                System.out.println("Do you want to buy "+ arrays.property_name[vars.player_position]+"?");
                System.out.println("It costs $"+ arrays.property_price[vars.player_position]+" and you have $"+vars.player_money);
                System.out.println("1 = yes; 2 = no");
                vars.selection = keyboard.nextInt();
                if (vars.selection == 1) {
                        System.out.println("You now own "+ arrays.property_name[vars.player_position]);
                        vars.player_money = vars.player_money - arrays.property_price[vars.player_position];
                        arrays.property_type[vars.player_position] = 1;
                } 
                if(vars.selection==2){
                        System.out.println("You do not buy "+ arrays.property_name[vars.player_position]);
                }
                
        }
        
        @SuppressWarnings("resource")
        public static void jail(){
                Scanner keyboard;
                keyboard = new Scanner(System.in);
                do {
                        vars.finished = 0;
                        System.out.println("You are in jail. What do you want to do?");
                        System.out.println("1:Spend $50 to get out");
                        System.out.println("2:Use a get out of jail free card");
                        if (vars.player_jail < 3) {
                                System.out.println("3:Try to roll doubles");
                        }
                        vars.selection = keyboard.nextInt();
                        if (vars.selection == 1) {
                                System.out.println("You pay $50 and get out of jail.");
                                vars.player_money = vars.player_money - 50;
                                vars.player_jail = 0;
                                vars.finished=1;
                        }else if (vars.selection == 2) {
                                System.out.println("sorry cards not implemented yet");
                        }else if(vars.selection==3&&vars.player_jail<3){
                                vars.dice = dice.dice_roll(vars.dice);
                                vars.var=dice.dice_roll(vars.dice);
                                if(vars.dice==vars.var){
                                        System.out.println("You rolled doubles!");
                                        vars.player_jail=0;
                                        vars.finished=1;
                                }
                        }else{
                                System.out.println("Not an option. Choose Again");
                        }
                } while (vars.finished == 0);
        }
        
        public static void property_scanner(){
                vars.var=0;
                if(arrays.property_type[1]==1&&arrays.property_type[3]==1){
                        vars.var++;
                        System.out.println("You own all of the purple properities");
                }
                if(arrays.property_type[6]==1&&arrays.property_type[8]==1&&arrays.property_type[9]==1){
                        vars.var++;
                        if(vars.var==1){
                                System.out.println("You own all of the light blue");
                        }else{
                                System.out.print(", light bule");
                        }
                        
                }
                if(arrays.property_type[6]==1&&arrays.property_type[8]==1&&arrays.property_type[9]==1){
                        vars.var++;
                        if(vars.var==1){
                                System.out.println("You own all of the purple");
                        }else{
                                System.out.print(", light bule");
                        }
                        
                }
                if(arrays.property_type[6]==1&&arrays.property_type[8]==1&&arrays.property_type[9]==1){
                        vars.var++;
                        if(vars.var==1){
                                System.out.println("You own all of the purple");
                        }else{
                                System.out.print(", light bule");
                        }
                        
                }
                if(arrays.property_type[6]==1&&arrays.property_type[8]==1&&arrays.property_type[9]==1){
                        vars.var++;
                        if(vars.var==1){
                                System.out.println("You own all of the purple");
                        }else{
                                System.out.print(", light bule");
                        }
                        
                }
        }
        
        public static int railroadRent(){
                vars.var = 0;
                if (arrays.property_type[5] == 2) {
                        vars.var++;
                }
                if (arrays.property_type[15] == 2) {
                        vars.var++;
                }
                if (arrays.property_type[25] == 2) {
                        vars.var++;
                }
                if (arrays.property_type[35] == 2) {
                        vars.var++;
                }
                if (vars.var == 1) {
                        vars.var = 25;
                }
                if (vars.var == 2) {
                        vars.var = 50;
                }
                if (vars.var == 3) {
                        vars.var = 100;
                }
                if (vars.var == 4) {
                        vars.var = 200;
                }
                return vars.var;
        }
        
}